<?php


namespace app\agent\controller;

class Recharge extends AdminBase
{
	public function use_card()
	{
		$options = $this->request->post();
		$validate = \think\Validate::make(["card" => "require"], ["card.require" => "card 不能为空"]);
		if (!$validate->check($options)) {
			$this->response(\app\agent\model\Code::fail, $validate->getError());
		}
		$options["agent_id"] = $this->admin_info["id"];
		$result = \app\agent\service\RechargeService::use_card($options);
		if ($result["code"] == 1) {
			$this->response($result["code"], "充值成功");
		} else {
			$this->response($result["code"], $result["msg"]);
		}
	}
	public function recharge_money_order()
	{
		$options = $this->request->post();
		$validate = \think\Validate::make(["money" => "require|float|>=:0.01", "pay_type" => "require|in:1,2,3"], ["money.require" => "充值金额 不能为空", "pay_type.require" => "付款方式 不能为空"]);
		if (!$validate->check($options)) {
			$this->response(\app\agent\model\Code::fail, $validate->getError());
		}
		$options["agent_id"] = $this->admin_info["id"];
		$result = \app\agent\service\RechargeService::recharge_money_order($options);
		if ($result["code"] == 1) {
			$this->response($result["code"], "下单成功", $result["data"]);
		} else {
			$this->response($result["code"], $result["msg"]);
		}
	}
}